package com.example.shop_2302

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.setupWithNavController
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.example.base.mvvm.BaseViewActivity
import com.example.shop_2302.databinding.ActivityShopBinding

/**
 * 电商主页
 */
@Route(path = "/app/ShopActivity")
class ShopActivity : BaseViewActivity<ActivityShopBinding>() {
    @Autowired
    @JvmField
    var position = 0
    override fun initView() {
        //接收告知信息
        ARouter.getInstance().inject(this)
        //找到导航宿主fragment
        val navHostFragment =
            supportFragmentManager.findFragmentById(R.id.fragmentContainerView) as NavHostFragment
        //找到导航器
        val navController = navHostFragment.navController
        //和底部联动
        binding.bottom.setupWithNavController(navController)

        //动态获取权限
        requestPermissions(arrayOf("android.permission.READ_EXTERNAL_STORAGE","android.permission.WRITE_EXTERNAL_STORAGE"),100)
        //根据告知信息，展示指定fragment
        when(position){
            0->binding.bottom.selectedItemId = R.id.homeFragment
            1->binding.bottom.selectedItemId = R.id.categoryFragment
            2->binding.bottom.selectedItemId = R.id.carFragment
            3->binding.bottom.selectedItemId = R.id.mineFragment
        }
    }

    override fun initData() {

    }

    override fun getLayout(): Int = R.layout.activity_shop

}